package demo.Thread;

import java.util.ArrayList;
import java.util.Random;
import java.util.UUID;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/10-08-10-17:07
 * @Description：demo.Thread
 */
public class ThreadOfArraylist {
    public static void main(String[] args) {
//        Thread thread1 = new myThread();
//        Thread thread2 = new myThread();
//        Thread thread3 = new myThread();
//        Thread thread4 = new myThread();
//        Thread thread5 = new myThread();
//        thread1.start();
//        thread2.start();
//        thread3.start();
//        thread4.start();
//        thread5.start();
        ArrayList<Integer> list = new ArrayList<>();
        //模拟10个线程，往ArrayList集合中添加数据
        for(int i=1;i<=10;i++){
            new Thread(()->{
                //list.add(UUID.randomUUID().toString().substring(0,8));
                list.add(new Random().nextInt(10));
                System.out.println(list);
            }).start();
        }

    }

}

